<?php

// Place in ./app/controllers/entries_controller.php

class EntriesController extends AppController {

  function add() {
    if (!empty($this->data)) {
      if ($this->Entry->save($this->data)) {
        $this->Session->setFlash('Added');
        $this->redirect(array('action'=>'index'));
      } else {
        $this->Session->setFlash('There was a problem with your section element');
      }
    }
  } // add()

  function delete($id = NULL) {
    $this->Entry->delete($id);
    $this->Session->setFlash("Deleted");
    $this->redirect(array('action'=>'index'));
  } // delete()

  function mark_read() {
		$resp = new stdClass();
		$resp->success = false;
		$resp->message = '';
		
		if (is_array($this->data)) {
			$this->Entry->setReadStatus($this->data);
			$resp->success = true;
			$resp->message = 'success';
		} else {
			$resp->success = false;
			$resp->message = 'IDs not sent';
		}
  } // mark_read()
	
	function mark_unread() {
		$resp = new stdClass();
		$resp->success = false;
		$resp->message = '';
		
		if (is_array($this->data)) {
			$this->Entry->setReadStatus($this->data, false);
			$resp->success = true;
			$resp->message = 'success';
		} else {
			$resp->success = false;
			$resp->message = 'IDs not sent';
		}
  } // mark_read()
	

} // class Entries

?>